/**************************************************************************************************
* Title: SumResourceManager.h
* Author: Gael Huber
* Description: Manages all renderable resources used for engine.
**************************************************************************************************/
#ifndef __SUMRESOURCEMANAGER_H__
#define __SUMRESOURCEMANAGER_H__

#include "SumSingleton.h"
#include "SumHashMap.h"
#include "SumString.h"
#include "SumResourceGroup.h"
#include "SumRenderEntity.h"
#include "SumMeshManager.h"	

#include <fstream>

using namespace std;

class ResourceManager : public Singleton<ResourceManager> {
public:
	ResourceManager(void);	// Constructor
	virtual ~ResourceManager(void);	// Destructor

	// Get singleton
	inline static ResourceManager& getSingleton(void)
	{
		assert(singleton);
		return *singleton;
	}
	// Get singleton pointer
	inline static ResourceManager* getSingletonPtr(void)
	{
		return singleton;
	}

	void startUp(void);		// Initialize in-game resources
	void shutDown(void);	// Shut down in-game resources

	// Create a render entity
	RenderEntity createRenderEntity(const String& entName, const String& meshName);

	// Request a mesh
	Mesh* requestMesh(const String& meshName);

private:
	// Initialize resource groups
	void _initializeResourceGroups(void);

	// Read a line from a file
	void _readLine(fstream& stream, char* cLine, String& sLine, std::streamsize count = 256);

	// Resource groups
	HashMap<String, ResourceGroup*> resourceGroups;
};
#endif